[VB.NET] Same name methods in different modules cause ambiguity.

Posted by smwikipedia on Stack Overflow See other posts from Stack Overflow or by smwikipedia
Published on 2010-05-20T11:21:25Z Indexed on 2010/05/20 11:30 UTC
Read the original article Hit count: 148

Filed under:

I have 2 modules. Each contains a Sub with the same name. See below:

Module moduleA
    Public Sub f(ByVal arg1 As myType)
        Console.WriteLine("module A")
    End Sub
End Module

Module moduleB
    Public Sub f(ByVal arg1 As myType, ByVal arg2 As Boolean)
        Console.WriteLine("module B")
    End Sub
End Module

But the compiler complains that there's ambiguity between moduleA and moduleB.

How could this be? I have totally different signatures.

However, if I put the 2 methods into the same module, there's no ambiguity at all.

Could someone tell me why?

Many thanks.

© Stack Overflow or respective owner

Related posts about vb.net